/**
 * 对学科进行排序
 * @param { Array } arr 需要排序的数组
 * @param { String } prop  排序的标准 
 */ 
export const order = (arr, prop)=>{
    if(arr.length <= 1) return arr; 
    let flag = false;
    for(let i = 0, len = arr.length - 1; i < len; i++){
        flag = true;
        for(let j = 0; j < arr.length - 1 - i; j++){ 
            if(arr[j][prop] > arr[j+1][prop]){
                flag = false;
                let temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
        if(flag) break;
    }   
    return arr;
};
export const histroyCookieDel=()=>{
    if(window.location.href.indexOf("?")){
      let href=window.location.href
      let delStart=href.indexOf("?");
      let delEnd=href.indexOf("#");
      let delStr='',targetFal='',target='';
      if(delEnd>delStart){
        delStr=href.slice(delStart,delEnd);
        targetFal=href.slice(delStart+1,delEnd);
        target=href.replace(delStr,'');
      }else{
        delStr=href.slice(delStart,href.length);
        targetFal=href.slice(delStart+1,href.length);
        target=href.replace(delStr,'');
      }
      history.pushState(null, null, target);
     
    }
  }
  export const  getCookie=(name)=> {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    arr = document.cookie.match(reg)
    if (arr) {
      return unescape(arr[2]);
    } else {
      return null;
    }
  }